<?php
/**
 * Show a search box and two buttons for searching an MVD. 
 * When the user clicks on a button submit to the controller, 
 * which automatically handles the response.
 */
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
require_once('IconButton.php');
// passed-in params
$pattern = $attribs['pattern'];
$searchboxId = $attribs['searchboxId'];
$leftButton = $attribs['leftButton'];
$searchButton = $attribs['searchButton'];
$searchAllButton = $attribs['searchAllButton'];
$rightButton1 = $attribs['rightButton1'];
$rightButton2 = $attribs['rightButton2'];
// computed params
$searchPrompt = JText::_('SEARCH_PROMPT'); 
$searchTitle = JText::_('SEARCH_TITLE'); 
$searchId = 'search'.$searchboxId;
$searchAllTitle = JText::_('SEARCH_ALL_TITLE'); 
$patternId = 'pattern'.$searchboxId;

?>
<div id="searchbox<?php echo $searchboxId;?>" class="searchbox">
<script type="text/javascript">
function dosearch<?php echo $searchboxId;?>(task)
{
	var patternField = document.getElementById( "<?php echo $patternId;?>" );
	var searchBox = document.getElementById("<?php echo $searchId;?>");
	var taskField = document.getElementById("task");
	patternField.value = searchBox.value;
	taskField.value = task;
	versionField = document.getElementById("version<?php echo $searchboxId;?>");
	nameField = document.getElementById("name");
	document.submission.submit();
}
function toggleIcon( id )
{
}
</script>
<table width="100%"><tr><td align="left">
<?php 
if ( $leftButton )
{
	$ib = new IconButton($leftButton);
	echo $ib->toHTML();
}
?>
</td><td align="center">
<input type="text" id="<?php echo $searchId;?>" 
	value="<?php echo $pattern;?>">
</input>
<?php 
$ib1 = new IconButton($searchButton);
$ib2 = new IconButton($searchAllButton);
echo $ib1->toHTML();
echo $ib2->toHTML();
?>
<input type="hidden" id="<?php echo $patternId;?>" name="<?php echo $patternId;?>" value="" />
</td><td align="center">
<?php
if ( $rightButton1 )
{
	$ib = new IconButton($rightButton1);
	echo $ib->toHTML()." ";
}
if ( $rightButton2 )
{
	$ib = new IconButton($rightButton2);
	echo $ib->toHTML()."\n";
}
?>
</td></tr></table>
</div>
